package com.lizhe.config.controller;

import com.lizhe.config.config.FamilyProperties;
import com.lizhe.config.config.FamilyYml;
import com.lizhe.config.config.PersonProperties;
import com.lizhe.config.model.Child;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 类描述:
 *
 * @author Lz on 2021-10-21
 */
@Controller
public class ConfigController {

    @Resource
    private PersonProperties personProperties;

    @Resource
    private FamilyProperties familyProperties;

    @Resource
    private FamilyYml familyYml;

    @GetMapping("/config")
    public void hello(HttpServletRequest req, HttpServletResponse resp) {
        // 配置文件
        PersonProperties properties = new PersonProperties();
        System.out.println(properties.toString());

        // 打印 Person的配置
        System.out.println("Person===>" + this.personProperties.getName() + "==" + this.personProperties.getAge());


        // 打印Family 额外配置
        System.out.println("familyYml===>" + familyYml.toString());


        // 打印Family配置
        // System.out.println("familyProperties===>" + familyProperties.toString());
        // Child child = familyProperties.getChild();
        // child.getFriends().forEach(item -> {
        //     System.out.println("friend==>" + item.getHobby());
        // });
        // Family===>FamilyProperties(
        // familyName=happy family,
        // father=Father(name=lizhe, age=19),
        // mother=null, child=null)

    }

}
